package acwing;

import java.io.*;
import java.util.*;

public class multiBag {
    static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
    static BufferedReader bin = new BufferedReader(new InputStreamReader(System.in));
    static final int N = 12010, M = 2010;
    static int n, m;
    static int[] v = new int[N], w = new int[N];
    static int[] f = new int[M];
    static int cin() throws IOException {
        in.nextToken();
        return (int) in.nval;
    }

    public static void main(String[] args) throws IOException {
        n = cin(); m = cin();
        int cnt = 0;
        for (int i = 1; i <= n; i ++ ) {
            int a = cin(), b = cin(), s = cin();
            int k = 1;
            while ( k <= s) {
                cnt ++ ;
                v[cnt] = a * k;
                w[cnt] = b * k;
                s -= k;
                k *= 2;
            }
            if (s > 0) {
                cnt ++ ;
                v[cnt] = a * s;
                w[cnt] = b * s;
            }
        }
        for (int i = 1; i <= cnt; i ++ ) {
            for (int j = m; j >= v[i]; j -- ) {
                f[j] = Math.max(f[j], f[j - v[i]] + w[i]);
            }
        }
        out.println(f[m]);
//        out.println(cnt);
        out.close();
    }
}
